const socketServer = require('../server/socketServer');

module.exports = {
    bindWs(ws, wsid) {
        socketServer.bindWs(wsid, (err, result) => {
            if (!result||result.length <= 0) {
                socketServer.addWs(JSON.stringify(ws), wsid, (err2, res2) => {
                    console.log('绑定Ws成功');
                    ws.send(JSON.stringify({
                        type: 'result',
                        data: 'success'
                    }));
                })
            } else {
                socketServer.updeteWs(JSON.stringify(ws), wsid, (err2, res2) => {
                    console.log('更新Ws成功');
                    ws.send(JSON.stringify({
                        type: 'result',
                        data: 'success'
                    }));
                })
            }
        })
    },
    delWs(wsid) {
        socketServer.delWs(wsid, (err, res) => {
            console.log(res);
        })
    }
}